<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>
<%
	if(session.getAttribute("password2")==null){
		response.sendRedirect( "login2.jsp?pageUrl=user/cp.jsp");
		return;
	}
String authType = request.getParameter("authType");
if(authType == null || authType.length() == 0){
	authType = String.valueOf(1);
}
request.setAttribute("authType", authType);



%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title><fmt:message key="i18n.title"/> </title>
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	
	<link rel="shortcut icon" href="../index/favicon.png" />
	
	<!-- bootstrap -->
    <link href="css/bootstrap/bootstrap.css" rel="stylesheet" />
    <link href="css/bootstrap/bootstrap-responsive.css" rel="stylesheet" />
    <link href="css/bootstrap/bootstrap-overrides.css" type="text/css" rel="stylesheet" />

    <!-- global styles -->
    <link rel="stylesheet" type="text/css" href="css/elements.css" />
    <link rel="stylesheet" type="text/css" href="css/icons.css" />
    
    <!-- this page specific styles -->
    <link rel="stylesheet" href="css/compiled/new-user.css" type="text/css" media="screen" />
    
    <script type="text/javascript" src="../scripts/jquery-1.11.0.min.js"></script>
</head>
<body>

	<!-- main container -->
	<div class="content container-fluid">
		<!-- BreadcrumbNavigation -->
        <div class="row-fluid head">
            <div class="span12">
                <h4><fmt:message key="i18n.userCenter"/> &gt; <fmt:message key="i18n.updatePassword"/>
                 &gt;<c:if test="${authType eq '1' }"><fmt:message key="i18n.changePasswordByOriginal" /></c:if><c:if test="${authType eq '2' }"><fmt:message key="i18n.changePasswordByMobile" /></c:if>
                </h4>
            </div>
        </div>
        <!-- End BreadcrumbNavigation -->
        
        <div class="container-fluid">
            <div id="pad-wrapper" class="new-user">

                <div class="row-fluid form-wrapper">
                    <!-- left column -->
                    <div class="span9 with-sidebar">
                        <div class="container">
                        	<form class="" id="cp1_form" action="registerUser!changePassword.action" method="post" >
						      	<input type="hidden" id="cp1_loginName" name="registerUserDTO.loginName" value="${session.loginName }" />
						      	<input type="hidden"  name="pageUrl" value="cp.jsp?authType=${authType }" />
						      	<input type="hidden"  name="registerUserDTO.authType" value="${authType }" />
						      	
						      	<div class="ctr">
						      		
						      		<p class="ctrL" style="line-height: 29px;">
						      			<c:if test="${authType ne '1' }"><a href="cp.jsp?authType=1"><fmt:message key="i18n.changePasswordByOriginal" /></a></c:if>
						      			<c:if test="${authType ne '2' }"><a href="cp.jsp?authType=2"><fmt:message key="i18n.changePasswordByMobile" /></a></c:if>
						      		</p>
						      	</div>
						      	<c:if test="${authType eq '1' }"><!-- 原密码 -->
						      	<div class="ctr">
									<p class="ctrL"><span style="font-weight: 600;"><fmt:message key="i18n.loginPassword" /></span><span style="color: red;">（<fmt:message key="i18n.notChangeNull" />）</span></p>
									<div class="ctrR">
										<div class="ctrRBox">
											<p class="ctrRBox1"><fmt:message key="i18n.currentPassword" />：</p>
											<input class="span9" type="password" name="registerUserDTO.oldPassword1" id="cp1_oldPassword1">
										</div>
										<div class="ctrRBox">
											<p class="ctrRBox1"><fmt:message key="i18n.newPassword"/>：</p>
											<input class="span9" type="password" name="registerUserDTO.password1" id="cp1_newPassword">
										</div>
										<div class="ctrRBox">
											<p class="ctrRBox1"><fmt:message key="i18n.cofimPassword"/>：</p>
											<input class="span9"  type="password" id="cp1_cofimPassword">
										</div>
									</div>
								</div>
								<div class="ctr">
									<p class="ctrL"><span style="font-weight: 600;"><fmt:message key="i18n.tradePassword" /></span><span style="color: red;">（<fmt:message key="i18n.notChangeNull" />）</span></p>
									<div class="ctrR">
										<div class="ctrRBox">
											<p class="ctrRBox1"><fmt:message key="i18n.currentPassword" />：</p>
											<input class="span9" type="password" name="registerUserDTO.oldPassword2" id="cp2_oldPassword2">
										</div>
										<div class="ctrRBox">
											<p class="ctrRBox1"><fmt:message key="i18n.newPassword"/>：</p>
											<input class="span9" type="password" name="registerUserDTO.password2" id="cp2_newPassword" >
										</div>
										<div class="ctrRBox">
											<p class="ctrRBox1"><fmt:message key="i18n.cofimPassword"/>：</p>
											<input class="span9" type="password" id="cp2_cofimPassword" >
										</div>
									</div>
								</div>
								<div class="ctr">
									<p class="ctrL">&nbsp;</p>
									<div class="ctrR1">
										<c:if test="${not empty session.activationTime}">
						     			<div class="ctrR1Box">
											<input type="button" class="ctrR1BoxAn" onclick="changePassword1()" value="&nbsp;&nbsp;&nbsp;&nbsp;<fmt:message key="i18n.update"/>&nbsp;&nbsp;&nbsp;&nbsp;" />
						     			</div>
						     			</c:if>
						     			<c:if test="${empty session.activationTime}">
										<fmt:message key="tip.activeTip" />
										</c:if>
									</div>
								</div>
						      	</c:if>
						      	<c:if test="${authType eq '2' }"><!-- 手机验证码 -->
								<div class="ctr">
									<p class="ctrL"><span style="font-weight: 600;"><fmt:message key="i18n.loginPassword" /></span><span style="color: red;">（<fmt:message key="i18n.notChangeNull" />）</span></p>
									<div class="ctrR">
										<div class="ctrRBox">
											<p class="ctrRBox1"><fmt:message key="i18n.newPassword"/>：</p>
											<input class="span9" type="password" name="registerUserDTO.password1" id="cp1_newPassword">
										</div>
										<div class="ctrRBox">
											<p class="ctrRBox1"><fmt:message key="i18n.cofimPassword"/>：</p>
											<input class="span9"  type="password" id="cp1_cofimPassword">
										</div>
									</div>
								</div>
								<div class="ctr">
									<p class="ctrL"><span style="font-weight: 600;"><fmt:message key="i18n.tradePassword" /></span><span style="color: red;">（<fmt:message key="i18n.notChangeNull" />）</span></p>
									<div class="ctrR">
										
										<div class="ctrRBox">
											<p class="ctrRBox1"><fmt:message key="i18n.newPassword"/>：</p>
											<input class="span9" type="password" name="registerUserDTO.password2" id="cp2_newPassword" >
										</div>
										<div class="ctrRBox">
											<p class="ctrRBox1"><fmt:message key="i18n.cofimPassword"/>：</p>
											<input class="span9" type="password" id="cp2_cofimPassword" >
										</div>
									</div>
								</div>
								<div class="ctr">
									<p class="ctrL">&nbsp;</p>
									<div class="ctrR1">
										<div class="ctrR1Box">
											<p class="ctrR1Box1" style=""><fmt:message key="i18n.valicode"/>：</p>
											<input class="ctrR1Box2" id="cp_validCode" name="registerUserDTO.authCode" >
											<input class="ctrR1Box3" type="button"  id="cp_loginName_button" value="<fmt:message key="i18n.getVerificationCode"/>" 
												onclick="getVerificationCode('Mobile','UpdatePassword','#cp1_loginName','#cp_loginName_button',true)"/>
						      				<input type="hidden" readonly="readonly" value="${session.mobile }" id="cp_loginName" />
										</div>
						     			<div class="ctrR1Box" align="center" style="margin: 0 0 20px 0;">
											<span style="color:red;" id="cp_loginName_show">&nbsp;</span>
						     			</div>
										<c:if test="${not empty session.activationTime}">
						     			<div class="ctrR1Box">
											<input type="button" class="ctrR1BoxAn" onclick="changePassword2()" value="&nbsp;&nbsp;&nbsp;&nbsp;<fmt:message key="i18n.update"/>&nbsp;&nbsp;&nbsp;&nbsp;" />
						     			</div>
						     			</c:if>
						     			<c:if test="${empty session.activationTime}">
										<fmt:message key="tip.activeTip" />
										</c:if>
									</div>
								</div>
								</c:if>
						      </form>
                        
                        </div>
                    </div> 
        	</div>
        </div>
	</div></div>


		<script src="../scripts/user/common.js"></script>
		<script type="text/javascript">
			var authType = "${authType}";
			$(function(){
				document.onkeydown = function(evt){
					var evt = window.event?window.event:evt;
					if(evt.keyCode==13){
						if(authType === '1'){
							changePassword1();
						}else{
							changePassword2();
						}
					}
				}
			});
			
			function changePassword1(){
				if(!hasText($('#cp1_oldPassword1').val())
						&& !hasText($('#cp2_oldPassword2').val())){
					/* alert('当前密码(登录密码)不能为空!');
					$('#cp1_oldPassword1').focus();return false; */
					alert('没有需要修改的密码');return;
				}
				if(hasText($('#cp1_oldPassword1').val())){
					if($('#cp1_newPassword').val()==''){
						alert('登录密码不能为空!');
						$('#cp1_newPassword').focus();
						return false;
					}
					if($('#cp1_newPassword').val()!=$('#cp1_cofimPassword').val()){
						alert('登录密码两次输入不正确!');
						$('#cp1_cofimPassword').focus();
						return false;
					}
				}
				/* if($('#cp1_newPassword').val()==''){
					alert('Login password can not be empty(登录密码不能为空)!');
					$('#cp1_newPassword').focus();
					return false;
				} */
				if(hasText($('#cp2_oldPassword2').val())){
					if($('#cp2_newPassword').val()==''){
						alert('交易密码不能为空!');
						$('#cp2_newPassword').focus();
						return false;
					}
					if($('#cp2_newPassword').val()!=$('#cp2_cofimPassword').val()){
						alert('交易密码两次输入不正确!');
						$('#cp2_cofimPassword').focus();
						return false;
					}
				}
				
				/* if($('#cp2_newPassword').val()==''){
					alert('Trading password can not be empty(交易密码不能为空)!');
					$('#cp2_newPassword').focus();
					return false;
				} */
				
				
				/* 
				if($('#cp_passwordAnswer').val()==''){
					alert('Secret security answer allowed is empty(密保答案不允许为空)!');
					$('#cp_passwordAnswer').focus();
					return false;
				} */
				/* if($('#cp_validCode').val()==''){
					alert('Verification code cannot be empty(验证码不能为空)!');
					$('#cp_validCode').focus();
					return false;
				} */
				/* $.post('activationCode!authEmailCode.action','dto.type=邮件&dto.category=UpdatePassword&dto.activationCode='+$('#cp_validCode').val(),function(res){
					 if(!res){
						 alert('E-mail verification code is not correct(邮箱验证码不正确)!');
						 return false;
					 }else{
						 $('#cp1_form').submit();
					 }
				}); */
				$('#cp1_form').submit();
			}
			function changePassword2(){
				if(!hasText($('#cp1_newPassword').val())
						&& !hasText($('#cp2_newPassword').val())){
					/* alert('当前密码(登录密码)不能为空!');
					$('#cp1_oldPassword1').focus();return false; */
					alert('没有需要修改的密码');return;
				}
				if(hasText($('#cp1_newPassword').val())){
					if($('#cp1_newPassword').val()==''){
						alert('登录密码不能为空!');
						$('#cp1_newPassword').focus();
						return false;
					}
					if($('#cp1_newPassword').val()!=$('#cp1_cofimPassword').val()){
						alert('登录密码两次输入不正确!');
						$('#cp1_cofimPassword').focus();
						return false;
					}
				}
				if(hasText($('#cp2_newPassword').val())){
					if($('#cp2_newPassword').val()==''){
						alert('交易密码不能为空!');
						$('#cp2_newPassword').focus();
						return false;
					}
					if($('#cp2_newPassword').val()!=$('#cp2_cofimPassword').val()){
						alert('交易密码两次输入不正确!');
						$('#cp2_cofimPassword').focus();
						return false;
					}
				}
				if($('#cp_validCode').val()==''){
					alert('验证码不能为空!');
					$('#cp_validCode').focus();
					return false;
				}
				$('#cp1_form').submit();
			}
		</script>
</body>
</html>